
package cn.edu.scau.cmi.hombio.service;

import cn.edu.scau.cmi.hombio.domain.Employee;
import cn.edu.scau.cmi.hombio.domain.FodderTake;
import cn.edu.scau.cmi.hombio.domain.FodderType;
import cn.edu.scau.cmi.hombio.domain.Task;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/pigRs-security-context.xml",
		"file:./resources/pigRs-service-context.xml",
		"file:./resources/pigRs-dao-context.xml",
		"file:./resources/pigRs-web-context.xml" })
@Transactional
public class FodderTakeServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected FodderTakeService service;

	/**
	 * Instantiates a new FodderTakeServiceTest.
	 *
	 */
	public FodderTakeServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	* Delete an existing FodderType entity
	* 
	 */
	@Test
	public void deleteFodderTakeFodderType() {
		// TODO: JUnit - Populate test inputs for operation: deleteFodderTakeFodderType 
		Integer foddertake_id = 0;
		Integer related_foddertype_id = 0;
		FodderTake response = null;
		response = service.deleteFodderTakeFodderType(foddertake_id, related_foddertype_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteFodderTakeFodderType
	}

	/**
	 * Operation Unit Test
	* Load an existing FodderTake entity
	* 
	 */
	@Test
	public void loadFodderTakes() {
		Set<FodderTake> response = null;
		response = service.loadFodderTakes();
		// TODO: JUnit - Add assertions to test outputs of operation: loadFodderTakes
	}

	/**
	 * Operation Unit Test
	* Delete an existing Task entity
	* 
	 */
	@Test
	public void deleteFodderTakeTask() {
		// TODO: JUnit - Populate test inputs for operation: deleteFodderTakeTask 
		Integer foddertake_id_1 = 0;
		Integer related_task_id = 0;
		FodderTake response = null;
		response = service.deleteFodderTakeTask(foddertake_id_1, related_task_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteFodderTakeTask
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findFodderTakeByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findFodderTakeByPrimaryKey 
		Integer id = 0;
		FodderTake response = null;
		response = service.findFodderTakeByPrimaryKey(id);
		// TODO: JUnit - Add assertions to test outputs of operation: findFodderTakeByPrimaryKey
	}

	/**
	 * Operation Unit Test
	* Save an existing FodderType entity
	* 
	 */
	@Test
	public void saveFodderTakeFodderType() {
		// TODO: JUnit - Populate test inputs for operation: saveFodderTakeFodderType 
		Integer id_1 = 0;
		FodderType related_foddertype = new cn.edu.scau.cmi.hombio.domain.FodderType();
		FodderTake response = null;
		response = service.saveFodderTakeFodderType(id_1, related_foddertype);
		// TODO: JUnit - Add assertions to test outputs of operation: saveFodderTakeFodderType
	}

	/**
	 * Operation Unit Test
	* Save an existing Employee entity
	* 
	 */
	@Test
	public void saveFodderTakeEmployeeByWarehousekepperId() {
		// TODO: JUnit - Populate test inputs for operation: saveFodderTakeEmployeeByWarehousekepperId 
		Integer id_2 = 0;
		Employee related_employeebywarehousekepperid = new cn.edu.scau.cmi.hombio.domain.Employee();
		FodderTake response = null;
		response = service.saveFodderTakeEmployeeByWarehousekepperId(id_2, related_employeebywarehousekepperid);
		// TODO: JUnit - Add assertions to test outputs of operation: saveFodderTakeEmployeeByWarehousekepperId
	}

	/**
	 * Operation Unit Test
	* Save an existing FodderTake entity
	* 
	 */
	@Test
	public void saveFodderTake() {
		// TODO: JUnit - Populate test inputs for operation: saveFodderTake 
		FodderTake foddertake = new cn.edu.scau.cmi.hombio.domain.FodderTake();
		service.saveFodderTake(foddertake);
	}

	/**
	 * Operation Unit Test
	* Return a count of all FodderTake entity
	* 
	 */
	@Test
	public void countFodderTakes() {
		Integer response = null;
		response = service.countFodderTakes();
		// TODO: JUnit - Add assertions to test outputs of operation: countFodderTakes
	}

	/**
	 * Operation Unit Test
	* Delete an existing Employee entity
	* 
	 */
	@Test
	public void deleteFodderTakeEmployeeByWarehousekepperId() {
		// TODO: JUnit - Populate test inputs for operation: deleteFodderTakeEmployeeByWarehousekepperId 
		Integer foddertake_id_2 = 0;
		Integer related_employeebywarehousekepperid_id = 0;
		FodderTake response = null;
		response = service.deleteFodderTakeEmployeeByWarehousekepperId(foddertake_id_2, related_employeebywarehousekepperid_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteFodderTakeEmployeeByWarehousekepperId
	}

	/**
	 * Operation Unit Test
	* Delete an existing Employee entity
	* 
	 */
	@Test
	public void deleteFodderTakeEmployeeByEmployeeId() {
		// TODO: JUnit - Populate test inputs for operation: deleteFodderTakeEmployeeByEmployeeId 
		Integer foddertake_id_3 = 0;
		Integer related_employeebyemployeeid_id = 0;
		FodderTake response = null;
		response = service.deleteFodderTakeEmployeeByEmployeeId(foddertake_id_3, related_employeebyemployeeid_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteFodderTakeEmployeeByEmployeeId
	}

	/**
	 * Operation Unit Test
	* Delete an existing FodderTake entity
	* 
	 */
	@Test
	public void deleteFodderTake() {
		// TODO: JUnit - Populate test inputs for operation: deleteFodderTake 
		FodderTake foddertake_1 = new cn.edu.scau.cmi.hombio.domain.FodderTake();
		service.deleteFodderTake(foddertake_1);
	}

	/**
	 * Operation Unit Test
	* Return all FodderTake entity
	* 
	 */
	@Test
	public void findAllFodderTakes() {
		// TODO: JUnit - Populate test inputs for operation: findAllFodderTakes 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<FodderTake> response = null;
		response = service.findAllFodderTakes(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllFodderTakes
	}

	/**
	 * Operation Unit Test
	* Save an existing Task entity
	* 
	 */
	@Test
	public void saveFodderTakeTask() {
		// TODO: JUnit - Populate test inputs for operation: saveFodderTakeTask 
		Integer id_3 = 0;
		Task related_task = new cn.edu.scau.cmi.hombio.domain.Task();
		FodderTake response = null;
		response = service.saveFodderTakeTask(id_3, related_task);
		// TODO: JUnit - Add assertions to test outputs of operation: saveFodderTakeTask
	}

	/**
	 * Operation Unit Test
	* Save an existing Employee entity
	* 
	 */
	@Test
	public void saveFodderTakeEmployeeByEmployeeId() {
		// TODO: JUnit - Populate test inputs for operation: saveFodderTakeEmployeeByEmployeeId 
		Integer id_4 = 0;
		Employee related_employeebyemployeeid = new cn.edu.scau.cmi.hombio.domain.Employee();
		FodderTake response = null;
		response = service.saveFodderTakeEmployeeByEmployeeId(id_4, related_employeebyemployeeid);
		// TODO: JUnit - Add assertions to test outputs of operation: saveFodderTakeEmployeeByEmployeeId
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
